package com.taichuan.keysupport;

import android.view.KeyEvent;

/**
 * Created by OISNY on 2016/8/18.
 */
public class Key {
    public static final int KEYCODE_1 = 0x01;
    public static final int KEYCODE_2 = 0x02;
    public static final int KEYCODE_3 = 0x03;
    public static final int KEYCODE_4 = 0x05;
    public static final int KEYCODE_5 = 0x06;
    public static final int KEYCODE_6 = 0x07;
    public static final int KEYCODE_7 = 0x09;
    public static final int KEYCODE_8 = 0x0A;
    public static final int KEYCODE_9 = 0x0B;

    public static final int KEYCODE_0 = 0x00;
    public static final int KEYCODE_XING = 0x08;
    public static final int KEYCODE_JING = 0x04;

    public static final int KEYCODE_OK = 0x11;
    public static final int KEYCODE_DEL = 0x13;
    public static final int KEYCODE_TAB = 0x12;
    public static final int KEYCODE_GLZHX = 0x10;

    public static final int KEYCODE_LONG_XING = 0x0D;
    public static final int KEYCODE_LONG_0 = 0x0C;
    public static final int KEYCODE_LONG_JING = 0x0E;

    public static final int KEYCODE_LONG_OK = 0x15;
    public static final int KEYCODE_LONG_DEL = 0x17;
    public static final int KEYCODE_LONG_TAB = 0x16;
    public static final int KEYCODE_LONG_GLZHX = 0x14;

    public static int convertKeyCode(int inputKeyCode) {
        int keyCode = inputKeyCode;
        switch (inputKeyCode) {
            case KEYCODE_0:
                keyCode = Convert.KEYCODE_0;
                break;
            case KEYCODE_1:
                keyCode = Convert.KEYCODE_1;
                break;
            case KEYCODE_2:
                keyCode = Convert.KEYCODE_2;
                break;
            case KEYCODE_3:
                keyCode = Convert.KEYCODE_3;
                break;
            case KEYCODE_4:
                keyCode = Convert.KEYCODE_4;
                break;
            case KEYCODE_5:
                keyCode = Convert.KEYCODE_5;
                break;
            case KEYCODE_6:
                keyCode = Convert.KEYCODE_6;
                break;
            case KEYCODE_7:
                keyCode = Convert.KEYCODE_7;
                break;
            case KEYCODE_8:
                keyCode = Convert.KEYCODE_8;
                break;
            case KEYCODE_9:
                keyCode = Convert.KEYCODE_9;
                break;
            case KEYCODE_XING:
                keyCode = Convert.KEYCODE_XING;
                break;
            case KEYCODE_JING:
                keyCode = Convert.KEYCODE_JING;
                break;
            case KEYCODE_OK:
                keyCode = Convert.KEYCODE_OK;
                break;
            case KEYCODE_DEL:
                keyCode = Convert.KEYCODE_DEL;
                break;
            case KEYCODE_TAB:
                keyCode = Convert.KEYCODE_TAB;
                break;
            case KEYCODE_GLZHX:
                keyCode = Convert.KEYCODE_GLZHX;
                break;
            case KEYCODE_LONG_XING:
                keyCode = Convert.KEYCODE_LONG_XING;
                break;
            case KEYCODE_LONG_0:
                keyCode = Convert.KEYCODE_LONG_0;
                break;
            case KEYCODE_LONG_JING:
                keyCode = Convert.KEYCODE_LONG_JING;
                break;
            case KEYCODE_LONG_OK:
                keyCode = Convert.KEYCODE_LONG_OK;
                break;
            case KEYCODE_LONG_DEL:
                keyCode = Convert.KEYCODE_LONG_DEL;
                break;
            case KEYCODE_LONG_TAB:
                keyCode = Convert.KEYCODE_LONG_TAB;
                break;
            case KEYCODE_LONG_GLZHX:
                keyCode = Convert.KEYCODE_LONG_GLZHX;
                break;
            default:
                keyCode = Convert.KEYCODE_DEFAULT_UNKONW;
                break;
        }
        return keyCode;
    }

    public static class L2KeyCode {
        public static final int KEYCODE_XING_CLS = Convert.KEYCODE_XING;
        public static final int KEYCODE_JING_OK = Convert.KEYCODE_JING;

        public static final int KEYCODE_UP = Convert.KEYCODE_OK;
        public static final int KEYCODE_DOWN = Convert.KEYCODE_DEL;
        public static final int KEYCODE_GLZX = Convert.KEYCODE_TAB;
        public static final int KEYCODE_HELP = Convert.KEYCODE_GLZHX;

        public static final int KEYCODE_LONG_XING = Convert.KEYCODE_LONG_JING;
        public static final int KEYCODE_LONG_0 = Convert.KEYCODE_LONG_0;
        public static final int KEYCODE_LONG_JING = Convert.KEYCODE_LONG_XING;

        public static final int KEYCODE_LONG_UP = Convert.KEYCODE_LONG_OK;
        public static final int KEYCODE_LONG_DOWN = Convert.KEYCODE_LONG_DEL;
        public static final int KEYCODE_LONG_GLZX = Convert.KEYCODE_LONG_TAB;
        public static final int KEYCODE_LONG_HELP = Convert.KEYCODE_LONG_GLZHX;

    }

    public class Convert {
        public static final int KEYCODE_1 = KeyEvent.KEYCODE_1;
        public static final int KEYCODE_2 = KeyEvent.KEYCODE_2;
        public static final int KEYCODE_3 = KeyEvent.KEYCODE_3;
        public static final int KEYCODE_4 = KeyEvent.KEYCODE_4;
        public static final int KEYCODE_5 = KeyEvent.KEYCODE_5;
        public static final int KEYCODE_6 = KeyEvent.KEYCODE_6;
        public static final int KEYCODE_7 = KeyEvent.KEYCODE_7;
        public static final int KEYCODE_8 = KeyEvent.KEYCODE_8;
        public static final int KEYCODE_9 = KeyEvent.KEYCODE_9;

        public static final int KEYCODE_0 = KeyEvent.KEYCODE_0;
        public static final int KEYCODE_XING = KeyEvent.KEYCODE_STAR;
        public static final int KEYCODE_JING = KeyEvent.KEYCODE_POUND;

        public static final int KEYCODE_OK = KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE;
        public static final int KEYCODE_DEL = KeyEvent.KEYCODE_BACK;
        public static final int KEYCODE_TAB = KeyEvent.KEYCODE_MEDIA_EJECT;
        public static final int KEYCODE_GLZHX = KeyEvent.KEYCODE_MEDIA_NEXT;

        public static final int KEYCODE_LONG_XING = KeyEvent.KEYCODE_MEDIA_STOP;
        public static final int KEYCODE_LONG_0 = KeyEvent.KEYCODE_MEDIA_PREVIOUS;
        public static final int KEYCODE_LONG_JING = KeyEvent.KEYCODE_MEDIA_RECORD;

        public static final int KEYCODE_LONG_OK = KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK;
        public static final int KEYCODE_LONG_DEL = KeyEvent.KEYCODE_MEDIA_CLOSE;
        public static final int KEYCODE_LONG_TAB = KeyEvent.KEYCODE_MEDIA_FAST_FORWARD;
        public static final int KEYCODE_LONG_GLZHX = KeyEvent.KEYCODE_MEDIA_PAUSE;

        /**
         * DEFAULT
         */
        public static final int KEYCODE_DEFAULT_UNKONW = KeyEvent.KEYCODE_MEDIA_REWIND;
    }
}
